package com.dg.river.module.common.adapter;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dg.river.R;
import com.luck.picture.lib.entity.LocalMedia;

import java.util.List;

/**
 * @author jrj
 * @description: 图片显示adapter
 * @date :2023/2/13 14:10
 * @update jrj 2022/11/11 规范代码的方法名，变量名等
 */
public class PicShowAdapter extends BaseQuickAdapter<LocalMedia, BaseViewHolder> {

    private int pic;

    public PicShowAdapter(int layoutResId, @Nullable List<LocalMedia> data, int mPic) {
        super(layoutResId, data);
        this.pic = mPic;
    }

    @Override
    protected void convert(BaseViewHolder helper, LocalMedia item) {
        if (item.getPosition() != -1) {
            Glide.with(mContext).load(item.getPath()).into((ImageView) helper.getView(R.id.ivAddPic));
            helper.setVisible(R.id.ivRemove, true);
        } else {
            Glide.with(mContext).load(pic).into((ImageView) helper.getView(R.id.ivAddPic));
            helper.setVisible(R.id.ivRemove, false);
        }
        helper.addOnClickListener(R.id.ivRemove);
        helper.addOnClickListener(R.id.ivAddPic);
    }
}
